﻿using System;
using System.Windows;
using CrateMayhem.Common.Services;

namespace CrateMayhem.Desktop.Services
{
    public class AutoCloseDialogService : IAutoCloseDialogService
    {
        private AutoCloseDialog dialog;
        public event EventHandler Closed;

        public void ShowDialog(string message, int delayBeforeClose = 3000)
        {
            dialog = new AutoCloseDialog(this, message, delayBeforeClose) { Owner = Application.Current.MainWindow };
            dialog.ShowDialog();
        }

        public void Close()
        {
            dialog.Close();

            if (Closed != null)
            {
                Closed(this, EventArgs.Empty);
            }
        }
    }
}